<?php
/*

Version 0.1
SEMF - Web Desiging Framework for Sport Event Managment
Copyright (C) 2006, SEMF Developers

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

*/
include_once($semf_root.'page_designer/components/Component.php');

class RadioGroupComponent extends Component
{

	
	/** properties with default values */
	public static function get_properties(){
		return array( 'Apearance' => array(
					 	'Fix-Count'=> 0,
						'Single'=> 0,
						'Hidden_label'=> 0),
					 'DataBinding' => array(
					 	'List' => '',
						'Value' => ''),
					 'Action Handlers'=> array(
							'onClick' => '')
					 );
	}
	
	
	/** build properties dynamically if atmost one property is changed */
	public static function build_properties($parent_container, $properties, $property_group, $key, $value)
	{
		if( $key != NULL )
		{
			$properties[$property_group][$key] = $value;
			if($key == 'Fix-Count')
			{
				$count = $properties["Apearance"]["Fix-Count"];
				$new_apearance = array();
				$new_apearance["Fix-Count"] = $count;
				for($i = 1; $i <= $count; $i ++)
				{
					if($properties["Apearance"]["Fix-Value".$i] == NULL)
					{
						$new_apearance["Fix-Value".$i] = "Sample".$i;
					}
					else
					{
						$new_apearance["Fix-Value".$i] = $properties["Apearance"]["Fix-Value".$i];
					}
				}
				$new_apearance["Single"] = $properties["Apearance"]["Single"];
				$new_apearance["Hidden_label"] = $properties["Apearance"]["Hidden_label"];
				$properties["Apearance"] = $new_apearance;
			}
		}
		return 	$properties;		
	}
	
	/** get the property info to use in databinding */
	public static function get_property_info($component_id, $properties)
	{
		$info_array = array();
		// first go for the List..
		$temp_array = array("List" => array(
									'attri' => 'value', //that is to get elem1.value 
									'databind'=> "_radio_span_".$component_id));
		$info_array = array_merge($info_array, $temp_array);
		
		$temp_array = array("Value" => array(
									'attri' => 'value', //that is to get elem1.value 
									'databind2'=> "_radio_".$component_id."_sec"));
		$info_array = array_merge($info_array, $temp_array);
		
		// Then for the Value..
		//print_r($info_array);
		return $info_array;
	}
	
	public static function get_action_info($component_id)
	{
		return array('onClick'=> array(
							'action' => action::$CLICK,
							'elem1' => "_radio_".$component_id,));
	}
}
?>